namespace yiCommerce.Data.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class order_trading : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.Order", "Trading_Id", "dbo.Tradings");
            DropIndex("dbo.Order", new[] { "Trading_Id" });
            CreateTable(
                "dbo.TradingOrders",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        OrderId = c.Int(nullable: false),
                        TradingId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Order", t => t.OrderId, cascadeDelete: true)
                .ForeignKey("dbo.Tradings", t => t.TradingId, cascadeDelete: true)
                .Index(t => t.OrderId)
                .Index(t => t.TradingId);
            
        }
        
        public override void Down()
        {
            DropIndex("dbo.TradingOrders", new[] { "TradingId" });
            DropIndex("dbo.TradingOrders", new[] { "OrderId" });
            DropForeignKey("dbo.TradingOrders", "TradingId", "dbo.Tradings");
            DropForeignKey("dbo.TradingOrders", "OrderId", "dbo.Order");
            DropTable("dbo.TradingOrders");
            CreateIndex("dbo.Order", "Trading_Id");
            AddForeignKey("dbo.Order", "Trading_Id", "dbo.Tradings", "Id");
        }
    }
}
